-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make strings in theme.json translatable #66675
Make strings in theme.json translatable #66675
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
theme.json
Outdated
@@ -0,0 +1 @@ | |||
lib/theme.json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd actually move the file instead of adding a symlink
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The lib/theme.json
location was working before; why change it now?
cc @oandregal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is explained in #66027
WP-CLI assumes that theme.json
only exists in a theme, and in themes it's required to be in the root. It does not look for any other subfolders and I don't wanna change that in WP-CLI.
The Gutenberg plugin is an exception because it holds the "source of truth" for theme.json
and does so in the lib
folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to catch up a bit on this, but last I checked (3 years ago) it was working fine (it extracted strings from core, Gutenberg, and themes).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes please test it again. But the way WP-CLI works hasn't changed: https://github.com/wp-cli/i18n-command/blob/0133eb1326e7e0613315dd94c347a2a03ee6f2d4/src/ThemeJsonExtractor.php#L19-L25
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More context: for testing, avoid using color gradients, palette, or font sizes. Some of these are also defined in the client (see) so it can give you false positives.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
However, if I do the same search for WordPress core and Gutenberg, there are no strings coming from
theme.json
With that current logic in WP-CLI that would be expected. As I said, it only looks for a specific location at the moment.
That change was made with the assumption that theme.json
is supposed to live only in themes and in the root folder of theme. This helped avoid an issue where, when extracting strings in core, theme.json
strings from all the default themes were erroneously included (because they live in wp-content
.
I suppose we didn't realize at the time that wp-includes/theme.json
also exists... 🤔
it sounds we haven't been extracting strings from the theme.json provided by WordPress (or Gutenberg) since 2 years ago?
Yes, you're right. Hmm we need to make some changes to WP-CLI then and to Meta (sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-gp-customizations/inc/cli/class-make-core-pot.php
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing the loop here: we're continuing the conversation at wp-cli/i18n-command#423
lib/theme-i18n.json
Outdated
"shadow": { | ||
"presets": [ | ||
{ | ||
"name": "Shadow presets name" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"name": "Shadow presets name" | |
"name": "Shadow preset name" |
Let's match the naming pattern
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we perhaps use Shadow name
instead? That's inline with what other presets do:
- font sizes: "font size name"
- colors: "color name"
- aspect ratios: "aspect ratio name"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also: these changes need to be backported to wordpress-develop so that the wp-cli uses them (see). Until then, these strings won't be picked up from anywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oandregal , I created a diff for wordpress-develop, but it instructs that the description should have a trac number. Do we have one, or do I create one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use https://meta.trac.wordpress.org/ticket/7866 I've left a comment linking to this PR and the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@oandregal I had created https://core.trac.wordpress.org/ticket/62728. I hope it isn't an issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's good as well 👍
@d-alleyne I think limiting the changes in this PR only to the theme-i18n.json and then preparing a similar PR for wordpress-develop would be best here. This will fast-track those changes. The other conversation (why WordPress and Gutenberg theme.json files aren't picked up for translation) is a bit tricky and may need more investigation. |
Co-authored-by: George Mamadashvili <[email protected]>
This reverts commit 42f4f5d.
@d-alleyne are you able to prepare the corresponding PR to https://github.com/WordPress/wordpress-develop/? You'd also need to push to this PR a new markdown file within |
While reviewing the core backport PR I realized there are some other things that need fixing, so I've prepared the PR at #68243 |
What?
Aspect Ratios and Shadow Presets are untranslated. The strings aren't in GlotPress.
Why?
This PR resolves the missing Aspect Ratios in #66027.
How?
By adding a symlink to
theme.json
in the project's root directory, strings will be extractedTesting Instructions
wp i18n make-pot .
.gutenberg.pot
file to confirm that the Aspect Ratio strings fromtheme.json
are not being extracted.N.B the
shadow.presets
strings are not extracted.Testing Instructions for Keyboard
Screenshots or screencast